<template>
  <div class="like-page">
   <van-nav-bar fixed title="我的喜欢"/>
     <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
     <article-item v-for="(item) in rows" :key="item.id" :item='item'></article-item>
     </van-list>
  </div>
</template>

<script>
import { getCollects } from '../api/article'
export default {
  name: 'like-page',
  data () {
    return {
      rows: [],
      current: 1,
      finished: false,
      loading: false
    }
  },
  methods: {
    async onLoad () {
      const res = await getCollects({
        page: this.current,
        pageSize: 10,
        optType: 1

      })
      // this.rows = this.rows.concat(res.data.data.rows)
      this.rows.push(...res.data.data.rows)
      // 加载完毕将loading设为false
      this.loading = false
      if (this.current >= res.data.data.pageTotal) {
        this.finished = true
      }
      // 让current自增
      this.current++
    }
  }
}
</script>

<style lang="less" scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
